import 'package:flutter/material.dart';
class ShopList extends StatefulWidget {
  const ShopList({super.key});

  @override
  State<ShopList> createState() => _ShopListState();
}

class _ShopListState extends State<ShopList> {
  Map goods = {
    "createTime": "2024-08-15 21:49:48",
    "orderState": 2,
    "image":
        "https://yanxuan-item.nosdn.127.net/a09de222ed32efa8ffe359b1d5780574.jpg",
    "name": "茶水分离杯耐热隔热玻璃杯",
    // "name": "茶水分离杯耐热",
    "totalNum": 2,
    "curPrice": 119.5,
    "totalMoney": 119.5,
    "attrsText": "规格:白色240ml",
  };

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      // 添加手势点击事件
      onTap: () {
        // 路由跳转方式1
        // Navigator.push(
        //   context,
        //   MaterialPageRoute(
        //     builder: (BuildContext context) {
        //       // 传参  在OrderDetail()中传入，并定义数据接收
        //       return OrderDetail();
        //     },
        //   ),
        // );

        // 路由跳转方式2
        // 传参在第三个参数中传
        Navigator.pushNamed(context, '/details', arguments: {'name': '小明'});
      },
      child: Container(
        padding: EdgeInsets.all(20),
        width: MediaQuery.of(context).size.width,
        height: 230,
        color: Colors.blueAccent,
        // 整体
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.end,
          spacing: 10,
          children: [
            // 1.日期-代发货
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text('${goods['createTime']}', style: TextStyle(fontSize: 15)),
                Text(
                  '${goods['orderState'] == 2 ? '待发货' : '待收货'}',
                  style: TextStyle(color: Colors.amber),
                ),
              ],
            ),
            // 2.商品信息
            Row(
              spacing: 5,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Image.network('${goods['image']}', width: 80),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    spacing: 5,
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Expanded(child: Text(goods['name'])),
                          Text('x ${goods['totalNum']}'),
                        ],
                      ),
                      Container(
                        padding: EdgeInsets.all(3),
                        color: const Color.fromARGB(255, 215, 220, 221),
                        child: Text(
                          '${goods['attrsText']}',
                          style: TextStyle(
                            fontSize: 10,
                            color: const Color.fromARGB(255, 245, 243, 243),
                          ),
                        ),
                      ),
                      Text(
                        '￥${goods['curPrice']}',
                        style: TextStyle(fontSize: 12),
                      ),
                    ],
                  ),
                ),
              ],
            ),
            // 3.合计-再次购买
            Column(
              children: [
                Text('合计:￥${goods['totalNum'] * goods['totalMoney']}'),
                Container(
                  padding: EdgeInsets.all(5),
                  decoration: BoxDecoration(border: Border.all(width: 1)),
                  child: Text('再次购买'),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
